import orm_login_json
def login():
    path = r'user.json'
    tag = 0
    name = input('请输入登录的用户名：')
    pwd = input('请输入登录的密码：')
    user_list = orm_login_json.read_data(path)
    for user in user_list:
        if name == user['username'] and pwd == user['password']:
            tag = 1
            break
    print("登录成功")
    return tag
def register():
    path= r'user.json'
    name=input("请输入注册的用户名：")
    pwd=input("请设置密码：")
    new_user={'username': name, 'password': pwd}
    user_list= orm_login_json.read_data(path)
    user_list.append(new_user)
    orm_login_json.write_data(user_list, path)
    print("注册成功")

#测试
if __name__ == '__main__':
    login()
    register()